using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using NWrapper.Config;
using NWrapper.Entities;

namespace NWrapper.Repositories
{
	/// <summary>
	/// Singleton instance of a repository that does nothing.
	/// </summary>
	public class NullRepository : IRepository
	{
		#region IRepository Members
		/// <summary>
		/// Initializes the repository; doesn't actually do anything.
		/// </summary>
		/// <param name="settings">The settings used for initialization.</param>
		public void Initialize(RepositorySettings settings)
		{
			//does nothing
		}

		/// <summary>
		/// Simulates finding the first instance of a given type.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		/// <returns>Always returns the default value of T.</returns>
		public T FindFirst<T>()
		{
			return default(T);
		}

		/// <summary>
		/// Simulates finding all instances of a given type.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		/// <returns>An empty collection.</returns>
		public IList<T> FindAll<T>()
		{
			return new Collection<T>();
		}

		/// <summary>
		/// Simulates saving an object to the repository.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		/// <param name="target">The object to save.</param>
		public void Save<T>(T target)
		{
			// does nothing
		}

		/// <summary>
		/// Simulates deleting an object from the repository.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		/// <param name="target">The object to delete.</param>
		public void Delete<T>(T target)
		{
			// does nothing
		}

		/// <summary>
		/// Simulates deleting all objects of a given type from the repository.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		public void DeleteAll<T>()
		{
			// does nothing
		}

		/// <summary>
		/// Simulates reloading an object from the repository.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		/// <param name="target">The object to reload.</param>
		/// <returns>The target object.</returns>
		public T Resync<T>(T target)
		{
			return target;
		}

		/// <summary>
		/// Gets the total number of records of a given type.
		/// </summary>
		/// <typeparam name="T">The object type.</typeparam>
		/// <returns>Always returns 0.</returns>
		public int CountAll<T>()
		{
			return 0;
		}
		#endregion
	}
}
